package com.mapperdb.mapper;

import java.util.List;

import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;

import com.mapperdb.helper.MapperProvider;

/**
 * 通用 Mapper
 * @author Administrator
 *
 * @param <T>
 */
public interface Mapper<T> {

	/**
	 * 查询
	 *
	 * @param entity
	 * @return
	 */
	@SelectProvider(type = MapperProvider.class, method = "selectOne")
	public T selectOne(T entity);

	/**
	 * 查询
	 *
	 * @param entity
	 * @return
	 */
	@SelectProvider(type = MapperProvider.class, method = "select")
	public List<T> selectList(T entity);

	/**
	 * 查询
	 *
	 * @param entity
	 * @return
	 */
	@SelectProvider(type = MapperProvider.class, method = "selectByPrimaryKey")
	public T selectByPrimaryKey(T entity);

	/**
	 * 查询
	 *
	 * @param entity
	 * @return
	 */
	@SelectProvider(type = MapperProvider.class, method = "selectByPrimaryKeySelective")
	public T selectByPrimaryKeySelective(T entity);

	/**
	 * 查询总数
	 *
	 * @param entity
	 * @return
	 */
	@SelectProvider(type = MapperProvider.class, method = "selectCount")
	public Integer selectCount(T entity);

	/**
	 * 插入全部
	 *
	 * @param entity
	 * @return
	 */
	@InsertProvider(type = MapperProvider.class, method = "insert")
	public Integer insert(T entity);

	/**
	 * 插入不为null的字段
	 *
	 * @param entity
	 * @return
	 */
	@InsertProvider(type = MapperProvider.class, method = "insertSelective")
	public Integer insertSelective(T entity);

	/**
	 * 通过条件删除
	 *
	 * @param entity
	 * @return
	 */
	@DeleteProvider(type = MapperProvider.class, method = "delete")
	public Integer delete(T entity);

	/**
	 * 通过主键删除
	 *
	 * @param entity
	 */
	@DeleteProvider(type = MapperProvider.class, method = "deleteByPrimaryKey")
	public Integer deleteByPrimaryKey(T entity);

	/**
	 * 通过主键更新全部字段
	 *
	 * @param entity
	 */
	@UpdateProvider(type = MapperProvider.class, method = "updateByPrimaryKey")
	public Integer updateByPrimaryKey(T entity);

	/**
	 * 通过主键更新不为null的字段
	 *
	 * @param ms
	 * @return
	 */
	@UpdateProvider(type = MapperProvider.class, method = "updateByPrimaryKeySelective")
	public Integer updateByPrimaryKeySelective(T entity);

}